home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Monster Media 1996 #15
/
Monster Media Number 15 (Monster Media)(July 1996).ISO
/
prog_c
/
cuj0696.zip
/
DWYER.ZIP
/
SPECTRAL.TST
/
PUTXINT.CX
< prev
next >
Wrap
Text File
|
1995-08-03
|
2KB
|
67 lines
/* ============ */
/* PutXInt.cx */
/* ============ */
#include <stdio.h>
#include <xtendefs.h>
#include <string.h>
/* ========================================================= */
/* fPutXInt - Prints integer part of extended value on Unit */
/* ========================================================= */
void
fPutXInt(FILE *Unit, USHORT *XVal, short MinFld)
{
char AscVal[128] = {0};
USHORT RndVal[NE];
short CharCt = 2, ExpVal;
char *CharLoc;
XROUND(XVal, RndVal);
XTOASC(RndVal, AscVal, NDEC);
CharLoc = strrchr(AscVal, 'E');
*CharLoc = '\0';
sscanf(CharLoc + 1, "%d", &ExpVal);
if (ExpVal < 0)
{
fprintf(Unit, " 0"); /* Minimum is two chars */
}
else
{
CharLoc = AscVal;
fprintf(Unit, "%c", *CharLoc++);/* First char is sign */
fprintf(Unit, "%c", *CharLoc++);/* Second char is digit */
++CharLoc; /* Third char is '.' */
for (; ExpVal; --ExpVal)
{
if (*CharLoc) /* Print next character */
{
fprintf(Unit, "%c", *CharLoc++);
}
else
{
fprintf(Unit, "0"); /* Pad with zeros on right */
}
++CharCt;
}
}
/* ------------------------------------- */
/* Fill Trailing Field Width with Blanks */
/* ------------------------------------- */
for (; CharCt < MinFld; ++CharCt)
{
fprintf(Unit, " ");
}
}
/* ========================================================= */
/* PutXInt - Prints integer part of extended value on stdout */
/* ========================================================= */
void
PutXInt(USHORT *XVal, short MinFld)
{
fPutXInt(stdout, XVal, MinFld);
}